<!--
 * @Author         : yanyongyu
 * @Date           : 2022-09-22 05:21:01
 * @LastEditors    : yanyongyu
 * @LastEditTime   : 2022-10-06 03:56:19
 * @Description    : None
 * @GitHub         : https://github.com/yanyongyu
-->

{% from "icons/issue-closed.html.jinja" import octicon_issue_closed %}
{% from "icons/issue-not-planned.html.jinja" import octicon_issue_not_planned %}

{% macro closed(event, ns) %}
{% if "merged" in ns.past_events|map(attribute="event")|list %}
{# already merged, hide closed #}
{% else %}
<div class="TimelineItem">
  {% if event.state_reason == "not_planned" %}
  <div class="TimelineItem-badge">
    {{ octicon_issue_not_planned(16, "color-fg-inherit") }}
  </div>
  {% else %}
  <div class="TimelineItem-badge color-fg-on-emphasis color-bg-done-emphasis">
    {{ octicon_issue_closed(16, "color-fg-inherit") }}
  </div>
  {% endif %}
  <div class="TimelineItem-body">
    <a>
      <img class="avatar avatar-user" height="20" width="20" src="{{ event.actor.avatar_url }}" />
    </a>
    <a class="author Link--primary text-bold">{{ event.actor.login|escape }}</a>
    closed this as
    {% if event.state_reason == "not_planned" %}
    <a href="#" class="Link--secondary">not planned</a>
    {% else %}
    <a href="#" class="Link--secondary">completed</a>
    {% endif %}
    <a class="Link--secondary">{{ event.created_at|relative_time }}</a>
  </div>
</div>
<div class="TimelineItem-break"></div>
{% endif %}
{% endmacro %}
